buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.3.15'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '8.0.2' apply false
    id 'com.android.library' version '8.0.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
    id 'com.google.gms.google-services' version '4.3.13' apply false
    id 'com.google.firebase.crashlytics' version '2.9.1' apply false
}
// For all subprojects - generate compileSdkVersion, minSdkVersion,
// targetSdkVersion and Java compatibility
subprojects {
    afterEvaluate { project ->
        if (project.plugins.findPlugin('android') ?:
                project.plugins.findPlugin('android-library')) {
            android {
                compileSdkVersion Config.compile_sdk

                defaultConfig {
                    minSdkVersion Config.min_sdk
                    targetSdkVersion Config.target_sdk
                }
                compileOptions {
                    sourceCompatibility Config.java_version
                    targetCompatibility Config.java_version
                }
                buildTypes.each {
                    Properties properties = new Properties()
                    properties.load(project.rootProject.file( "url.properties" ).newDataInputStream ())
                    def url = properties.getProperty( "baseUrl" , "" )
                    it.buildConfigField "String" , "BASE_URL" , url
                }
                buildFeatures {
                    viewBinding = true
                    buildConfig = true
                }
                testOptions {
                    unitTests {
                        includeAndroidResources = true
                    }
                }
                lintOptions {
                    checkReleaseBuilds false
                }
            }

            dependencies {

                //SplashScreen API
                implementation SplashScreen.core_splashscreen

                //Design
                implementation Design.appcompat
                implementation Design.material
                implementation Design.savedstate
                implementation Design.constraintlayout
                implementation Design.fragment_ktx
                implementation Design.ui_ktx
                implementation Design.swiperefreshlayout
                implementation Design.recyclerview
                implementation Design.viewmodel_ktx
                implementation Design.arCore

                //Kotlin
                implementation Kotlin.core
                implementation Kotlin.coroutines_core
                implementation Kotlin.coroutines_android
                // Android X
                implementation(Kotlin.splash_screen)

                //Koin
                implementation Koin.koin_android
                implementation Koin.koin_core
                implementation Koin.koin_compat

                //Retrofit
                implementation Retrofit.retrofit
                implementation Retrofit.converter_gson
                implementation Retrofit.adapter_coroutines
                implementation Retrofit.logging_interceptor

                //Cicerone
                implementation Cicerone.cicerone

                //Glide
                implementation Glide.glide_compiler
                implementation Glide.glide

                //Firebase
                implementation platform(Firebase.firebase_bom)
                implementation Firebase.firebase_auth
                implementation Firebase.firebase_database
                implementation Firebase.crashlytics_ktx
                implementation Firebase.messaging_ktx_app
                implementation Firebase.database_ktx_app
                implementation Firebase.analytics_ktx_version
                implementation Firebase.firebase_auth_ktx

                //TestImpl
                testImplementation TestImpl.junit
                androidTestImplementation TestImpl.espresso
                androidTestImplementation TestImpl.test_imlement_junit
                testImplementation TestImpl.core_testing
                //Mockito
                testImplementation Mockito.mockito_core
                testImplementation Mockito.mockito_inline
                testImplementation('com.nhaarman:mockito-kotlin:1.5.0') {
                    exclude group: 'org.jetbrains.kotlin'
                    exclude group: 'org.mockito'
                }

                //Robolectric Tests
                testImplementation Robolectric.robolectric
                testImplementation Robolectric.test_core
                testImplementation Robolectric.test_runner
                testImplementation Robolectric.test_junit
                testImplementation Robolectric.test_truth
                testImplementation Robolectric.test_espresso_core
                testImplementation Robolectric.test_espresso_intents
                implementation Robolectric.ar_core

                //Fragment Tests
                debugImplementation Automator.fragment_testing

                //UI Automator
                androidTestImplementation Automator.uiautomator
                androidTestImplementation Automator.test_rules

                //RecyclerView
                debugImplementation RecyclerView.espresso_contrib

                //CoroutineTests
                testImplementation CoroutineTests.coroutines_test
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}